// pages/newcomer/index.js
var app = getApp();
var rootDocment = app.globalData.postUrl;
Page({

  /**
   * 页面的初始数据
   */
  data: {
    kefu: wx.getStorageSync('kefu') ? wx.getStorageSync('kefu') : '',
    goodsList: [],
    userInfo: {},
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.setOrderGoodsData()
  },
  setOrderGoodsData: function () {
    var that = this;
    var paraArr = new Array();

    paraArr['size'] = "30";
    paraArr['sort'] = 108;
    paraArr['page'] = 1;
    paraArr['order'] = 'id';
    paraArr['order_type'] = 'desc';
    paraArr['user_id'] = wx.getStorageSync('user_id3');
    var sign = app.signature(paraArr);
    wx.request({
      url: rootDocment + '/api_goods',
      data: {
        sort: paraArr['sort'],
        page: paraArr['page'],
        order: paraArr['order'],
        order_type: paraArr['order_type'],
        size: paraArr['size'],
        user_id: paraArr['user_id'],
        sign: sign
      },
      method: 'GET',
      header: {},
      success: function (res) {
        that.setData({
          goodsList: [...res.data.data]
        });

      }
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    var that = this
    this.setData({
      is_shop: wx.getStorageSync('is_shop') || 0,
    })

    //用户授权登录
    app.login(function (userInfo) {
      that.setData({
        userInfo: userInfo,
        is_vip_price: userInfo.is_vip_price
      });
    });
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})